package de.baumann.browser.fragments.gg

import android.view.View
import de.baumann.browser.R
import de.baumann.browser.adapter.MineMortgageAdapter
import de.baumann.browser.api.net.vo.gg.Morgage
import de.baumann.browser.base.BaseOdinFragment
import de.baumann.browser.iview.gg.IMortgageRecordsView
import de.baumann.browser.present.gg.MortgageRecordsPresenter
import kotlinx.android.synthetic.main.fragment_mortgage_records.*

class MineMortgageRecordsFragment : BaseOdinFragment<IMortgageRecordsView, MortgageRecordsPresenter>(), IMortgageRecordsView {

    companion object {
        val instance: MineMortgageRecordsFragment by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            MineMortgageRecordsFragment()
        }
    }

    private lateinit var MineMortgageAdapter: MineMortgageAdapter

    override fun getLayout(): Int {
        return R.layout.fragment_mortgage_records
    }

    override fun initView(view: View) {
        MineMortgageAdapter =  MineMortgageAdapter()
        rvMortgageRecords.adapter = MineMortgageAdapter
    }

    override fun initData() {
        val id = arguments?.getString("id")
        if (id!=null){
            getPresenter().a02(id)
        }
    }

    override fun createPresenter(): MortgageRecordsPresenter {
        return MortgageRecordsPresenter()
    }

    override fun createView(): IMortgageRecordsView {
        return this
    }

    override fun setList(list: List<Morgage>) {
        MineMortgageAdapter.setNewData(list)
    }

}